﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using KCMS.BusinessLogic.Models;
using System.Web.Mvc;

namespace KCMS.Engine
{
    public class GenderListGenerator<T> where T:Alpha
    {
        public IEnumerable<SelectListItem> getGenderList(IEnumerable<T> list, Guid deafultId)
        {
            return list.Select(c => new SelectListItem
            {
                Text = c.Title,
                Value = c.Id.ToString(),
                Selected = (deafultId.Equals(c.Id)) ? true : false
            });
        }
        public IEnumerable<SelectListItem> getGenderList(IEnumerable<T> list)
        {
            return this.getGenderList(list, Guid.Empty);
        }
        public IEnumerable<SelectListItem> getGenderListWithEmptyOption(IEnumerable<T> list, Guid deafultId)
        {
            List<SelectListItem> result = this.getGenderList(list, deafultId).ToList();
            result.Add(new SelectListItem
            {
                Text = "",
                Value = Guid.Empty.ToString()
            });
            return result;
        }
        public IEnumerable<SelectListItem> getGenderListWithEmptyOption(IEnumerable<T> list)
        {
            List<SelectListItem> result = this.getGenderList(list, Guid.Empty).ToList();
            result.Add(new SelectListItem
            {
                Text = "",
                Value = Guid.Empty.ToString(),
                Selected = true
            });
            return result;
        }
    }
}